{template 'common/header'}

<div id="menu">
    <ul class="nav nav-tabs">
        <li {if $_GPC['action'] ==''}class="active"{/if}>
        <a href="{php echo $this->createWebUrl('notice', array('action' => ''));}">公告列表</a>
        </li>
        <li {if $_GPC['action'] == 'add'}class="active"{/if}>
        <a href="{php echo $this->createWebUrl('notice', array('action' => 'add'));}">公告添加</a>
        </li>

    </ul>
</div>

{if $_GPC['action'] == 'add'}
<form method="post" action="{php echo $this->createWebUrl('notice',array('action' => 'add','id'=>$res['id']))}" class="form-horizontal bv-form" role="form" novalidate="novalidate">
    <div class="panel panel-info">
        <div class="panel-heading">公告列表</div>
        <div class="panel-body">
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" >标题</label>
                <div class="col-sm-9 col-xs-12">
                    <input type="text" name="title" value="{$res['title']}" class="form-control" placeholder="请输入文章标题">
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" >通知内容</label>
                <div class="col-sm-9 col-xs-12">
                    {php echo tpl_ueditor('info',$res['info']);}
                </div>
            </div>
        </div>
        <div class="form-group" style="margin-left: 10%;">
            <div class="col-sm-9 col-xs-12">
                <input type="submit" value="提交" class="btn btn-primary">
            </div>
        </div>
    </div>
</form>
{/if}


{if $_GPC['action'] ==''}
<table class="table table-hover">
    <thead class="navbar-inner">
    <tr>
        <th>标题</th>
        <th>内容</th>
        <th style="width:250px;">操作</th>
    </tr>
    </thead>
    <tbody>
    {loop $res $v}
    <tr>
        <td>{$v['title']}</td>
        <td>{$v['info']}</td>
        <td>
            {if $v['state'] ==0}
            <a  class="btn btn-success btn-sm" onclick="show(1,'{$v[id]}')"  >隐藏</a>
            {else}
            <a  class="btn btn-info btn-sm" onclick="show(0,'{$v[id]}')" >显示</a>
            {/if}
            <a class="btn btn-warning btn-sm" href="{php echo $this->createWebUrl('notice',array('action'=>'add', 'id' => $v['id']));}">编辑</a>
            <a class="btn btn-danger btn-sm" href="{php echo $this->createWebUrl('notice',array('action'=>'delete', 'id' => $v['id']));}">删除</a>
        </td>
    </tr>
    {/loop}
    </tbody>
</table>
<div class="col-xs-12">
    {php echo $pager}
</div>
{/if}
{template 'common/footer'}
<script>
    function show(state ,id) {
        var a= confirm('确定修改？');
        if(a){
            $.ajax({
                url : "{php echo $this->createWebUrl('notice',array('action'=>'show'))}",
                type:"post",
                data:{
                    state : state,
                    id : id
                }, success: function (res) {

                    if(res==1) {
                        window.location.reload();
                    }else{
                        window.location.reload();
                    }
                }
            });
        }else{
            return false;
        }
    }
</script>